# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/19 下午4:17
 @Author  : tgy
 
"""
import time


def format():
    ...
    name = 'tony'
    print('name = %s' % name)
    print('name = {name}'.format(name=name))


def str_slice():
    ...
    name = 'zhangsan'
    print(name[2])
    # 取负数的位置为 len(str) + (-1)
    print(name[-1])
    print(name[0:-2])
    print(name[0:-1])

    print(name[::-1])


def test01():
    ...
    names = '123', '345'
    print(type(names))

    for i in range(1, 100):
        ...
        time.sleep(0.2)
        print('\r{0}'.format('#' * i), end='')


def generalA_Z():
    for x in range(65, 91):
        yield chr(x)


def test02():
    ...
    print(chr(65))
    print(ord('B'))
    print([x for x in generalA_Z()])


def test03():
    ...
    age = '10110'
    sum = 0
    while age:
        ...
        sum = (sum << 1) + ord(age[0]) - ord('0')
        age = age[1:]

    print(sum)


if __name__ == '__main__':
    ...
    # format()
    # str_slice()
    test03()
